﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using TyMES.Model.Record;


namespace TyMES.ViewModel.Record.CodeStoreVMs
{
    public partial class CodeStoreListVM : BasePagedListVM<CodeStore_View, CodeStoreSearcher>
    {

        protected override IEnumerable<IGridColumn<CodeStore_View>> InitGridHeader()
        {
            return new List<GridColumn<CodeStore_View>>{
                this.MakeGridHeader(x => x.Codevalue),
                this.MakeGridHeader(x => x.CodeTypeName),
                this.MakeGridHeader(x => x.orderCode),
                this.MakeGridHeader(x => x.schduleCode),
                this.MakeGridHeader(x => x.enable),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<CodeStore_View> GetSearchQuery()
        {
            var query = DC.Set<CodeStore>()
                .CheckContain(Searcher.Codevalue, x=>x.Codevalue)
                .CheckContain(Searcher.CodeTypeName, x=>x.CodeTypeName)
                .CheckContain(Searcher.orderCode, x=>x.orderCode)
                .CheckContain(Searcher.schduleCode, x=>x.schduleCode)
                .CheckEqual(Searcher.enable, x=>x.enable)
                .Select(x => new CodeStore_View
                {
				    ID = x.ID,
                    Codevalue = x.Codevalue,
                    CodeTypeName = x.CodeTypeName,
                    orderCode = x.orderCode,
                    schduleCode = x.schduleCode,
                    enable = x.enable,
                })
                .OrderByDescending(x => x.ID);
            return query;
        }

    }

    public class CodeStore_View : CodeStore{

    }
}
